import React, { useState } from "react";

export default function App() {
  const [counter, setCounter] = useState(100);
  const [flag, setFlag] = useState(false);
  const [list, setList] = useState([1, 2, 3, 4]);
  return (
    <div>
      <h1>{counter}</h1>
      <button onClick={() => setCounter(counter + 1)}>+</button>

      <hr />
      <div>{flag ? "显示" : "隐藏"}</div>
      <button onClick={() => setFlag(!flag)}>toggle</button>
      <hr />
      <button onClick={() => setList([...list, Date.now()])}>添加</button>
      <div>
        {list.map((item) => {
          return <p key={item}>{item}</p>;
        })}
      </div>
    </div>
  );
}
